#
#  pydococaAppDelegate.py
#  pydococa
#

from Foundation import *
from AppKit import *
import objc

from PyObjCTools import NibClassBuilder

def getMembers(item):
    q = 'dir('+ item +')'
    try:
        mem = eval(q)
    except:
        mem = []
    return mem

def getDoc(item):
    q = item +'.__doc__'
    try:
        doc = eval(q)
    except:
        doc = ''
    return doc

class pydococaAppDelegate(NibClassBuilder.AutoBaseClass):
    searchKey = ''
    text = ''
    members = []
    memberToSearch = ''

    def setSearchKey_(self, value):
        self.searchKey = value
        print self.searchKey
        
        if self.searchKey == None:
            self.text = 'Enter a method or module name.'
            self.members = getMembers('')
        else:
            self.text = getDoc(value)
            self.members = getMembers(value)

    def setMemberToSearch_(self, value):
        if value != None:
            self.setSearchKey_(self.searchKey + '.' + value)


